package lumis.service.search;

import lumis.doui.processaction.ProcessActionHandler;
import lumis.doui.search.SearchSource;
import lumis.doui.source.TabularSource;
import lumis.doui.source.field.ITabularSourceField;
import lumis.portal.PortalException;
import lumis.portal.manager.ManagerFactory;
import lumis.portal.serviceinstance.IServiceInstanceManager;

/**
 * Saves search properties for a DOUI service instance 
 *
 * @version $Revision: 7370 $ $Date: 2007-06-12 13:50:49 -0300 (Tue, 12 Jun 2007) $
 * @since 4.0.11
 */
public class SearchPropertiesProcessActionHandler extends ProcessActionHandler<TabularSource<ITabularSourceField>>
{
	public void processAction() throws PortalException
	{
		Boolean disableSearchInServiceInstance = getParameter("disableSearchInServiceInstance", Boolean.class); 
		String callerInterfaceInstanceId = douiContext.getRequest().getCallerServiceInterfaceInstanceId();
		String callerServiceInstanceId = ManagerFactory.getServiceInterfaceInstanceManager().get(sessionConfig, callerInterfaceInstanceId, transaction).getServiceInstanceId();
		IServiceInstanceManager serviceInstanceManager = ManagerFactory.getServiceInstanceManager();
		if (disableSearchInServiceInstance.booleanValue())
			serviceInstanceManager.setCustomProperty(sessionConfig, callerServiceInstanceId, SearchSource.SERVICE_INSTANCE_PROPERTY_DISABLE_SEARCH, disableSearchInServiceInstance.toString(), transaction);
		else
			serviceInstanceManager.deleteCustomProperty(sessionConfig, callerServiceInstanceId, SearchSource.SERVICE_INSTANCE_PROPERTY_DISABLE_SEARCH, transaction);
		addDefaultResponse();
	}
}
